package com.jxw.launcher.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import com.jxw.launcher.BaseThemeActivity;
import com.jxw.launcher.R;

/* loaded from: classes.dex */
public class UIImageView1 extends ImageView implements View.OnFocusChangeListener {
    private int HEIGHT;
    private int PAINT_ALPHA;
    private int WIDTH;
    private Paint mPaint;
    private int mPressedColor;
    private int mRadius;
    private int mShapeType;

    public UIImageView1(Context context) {
        super(context);
        this.PAINT_ALPHA = 48;
    }

    public UIImageView1(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.PAINT_ALPHA = 48;
        init(context, attributeSet);
    }

    public UIImageView1(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.PAINT_ALPHA = 48;
        init(context, attributeSet);
    }

    private void init(Context context, AttributeSet attributeSet) {
        if (isInEditMode()) {
            return;
        }
        setOnFocusChangeListener(this);
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.styleable.UIImageView);
        this.mPressedColor = obtainStyledAttributes.getColor(1, getResources().getColor(R.color.color_pressed));
        this.PAINT_ALPHA = obtainStyledAttributes.getInteger(0, this.PAINT_ALPHA);
        this.mShapeType = obtainStyledAttributes.getInt(3, 1);
        Log.e("zzj", "mShapeType = " + this.mShapeType);
        this.mRadius = obtainStyledAttributes.getDimensionPixelSize(2, getResources().getDimensionPixelSize(R.dimen.x4));
        obtainStyledAttributes.recycle();
        this.mPaint = new Paint();
        this.mPaint.setStyle(Paint.Style.FILL);
        this.mPaint.setColor(this.mPressedColor);
        setWillNotDraw(false);
        this.mPaint.setAlpha(0);
        this.mPaint.setAntiAlias(true);
        setDrawingCacheEnabled(true);
        setClickable(true);
    }

    @Override // android.view.View
    protected void onSizeChanged(int i, int i2, int i3, int i4) {
        super.onSizeChanged(i, i2, i3, i4);
        this.WIDTH = i;
        this.HEIGHT = i2;
    }

    @Override // android.widget.ImageView, android.view.View
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        Paint paint = this.mPaint;
        if (paint == null) {
            return;
        }
        if (this.mShapeType == 0) {
            int i = this.WIDTH;
            canvas.drawCircle(i / 2, i / 2, (i / 2.0f) - 2.0f, paint);
            return;
        }
        RectF rectF = new RectF();
        rectF.set(0.0f, 0.0f, this.WIDTH, this.HEIGHT);
        int i2 = this.mRadius;
        canvas.drawRoundRect(rectF, i2, i2, this.mPaint);
    }

    @Override // android.view.View
    public boolean onTouchEvent(MotionEvent motionEvent) {
        int action = motionEvent.getAction();
        if (action == 0) {
            this.mPaint.setAlpha(this.PAINT_ALPHA);
            invalidate();
        } else if (action == 1 || action == 3) {
            this.mPaint.setAlpha(0);
            invalidate();
        }
        return super.onTouchEvent(motionEvent);
    }

    @Override // android.view.View.OnFocusChangeListener
    public void onFocusChange(View view, boolean z) {
        Log.e("zzj", "onFocusChange view=" + view + "," + z + ",mBorderView=" + ((BaseThemeActivity) view.getContext()));
    }
}
